#!/bin/sh

kill_pid()
{
	echo $res
	pid_res=${res%%root*}
	echo $pid_res
	kill -9 $pid_res
	if [ $? -eq 0 ]
	then
		echo "sh net kill pid success"
	else
		echo "sh net kill pid failed"
	fi
}

brctl addbr br0
brctl stp br0 off
brctl addif br0 eth0
brctl addif br0 wlan0
ifconfig eth0 down
ifconfig wlan0 down
ifconfig eth0 0.0.0.0
ifconfig wlan0 0.0.0.0
ifconfig br0 192.168.42.251

res=$(ps -e | grep -a "hostapd")
kill_pid

res=$(ps -e | grep -a "dnsmasq")
kill_pid

sleep 8

hostapd -B /etc/hostapd.conf
dnsmasq
if [ $? -eq 0 ]
then
	echo "==========br0 DHCP init success========="
else
	echo "==========br0 DHCP init faild==========="
fi
